﻿<assign name="title" value="基本演示" />
<include file="top.html" />
    <script type="text/javascript">
        var demos=null;
        window.onload = function(){
            var trs = document.getElementById("list").getElementsByTagName("tr");
            demos = document.getElementById("demos");
            for(var i=0;i<trs.length;i++){
                var tds = trs[i].getElementsByTagName("td");
                var a = document.createElement("div");
                a.innerHTML = tds[0].innerHTML;
                a.onclick = (function(a,b,c,o){
                    return function(){
                        ShowDemo(o,a,b,c);
                    }
                })(tds[0].innerHTML,tds[1].innerHTML,tds[2].innerHTML,a);
                demos.appendChild(a);
            }
            var first = trs[0].getElementsByTagName("td");
            ShowDemo(demos.firstChild,first[0].innerHTML,first[1].innerHTML,first[2].innerHTML);
        };
        function ShowDemo(src, title, content, result){
            RemoveHover();
            src.className="hover";
            document.getElementById("demo_title").innerHTML = title;
            document.getElementById("demo_content").innerHTML = content;
            document.getElementById("demo_result").innerHTML = result;
        }
        function RemoveHover(){
            var chds = demos.childNodes;
            for(var i=0;i<chds.length;i++){
                chds[i].className="normal";
            }
        }
    </script>
    <h3>基本演示：程序-/App/Controllers/HomeController.asp，模板-/App/Views/default/Home/Home.html</h3>
    <div id="demos" class="clearfix"></div>
    <div id="deme_detail">
        <h4>项目：</h4>
        <div id="demo_title"></div>
        <h4>模板代码：</h4>
        <div id="demo_content"></div>
        <h4>执行结果：</h4>
        <div id="demo_result"></div>
    </div>
<table width="100%" class="list" style="display:none">
    <thead class="h">
        <tr><td width="10%">项目</td><td width="45%">模板代码</td><td>执行结果</td></tr>
    </thead>
    <tbody class="l" id="list">
        <tr>
            <td>基本变量输出</td>
            <td>{&#36;Version} ，{&#36;appname}</td>
            <td>{$Version}，{$appname}</td>
        </tr>
        <tr>
            <td>输出个日期看看</td>
            <td>{&#36;Debug}</td>
            <td><pre>{$Debug}</pre></td>
        </tr>
        <tr>
            <td>服务器变量</td>
            <td>{&#36;Mo.server.REMOTE_ADDR}</td>
            <td>{$Mo.server.REMOTE_ADDR}</td>
        </tr>
        <tr>
            <td>GET</td>
            <td>{&#36;Mo.get.name}</td>
            <td>{$Mo.get.name}</td>
        </tr>
        <tr>
            <td>POST</td>
            <td>{&#36;Mo.post.name}</td>
            <td>{$Mo.post.name}</td>
        </tr>
        <tr>
            <td>SESSION</td>
            <td>{&#36;Mo.session.name}</td>
            <td>{$Mo.session.name}</td>
        </tr>
        <tr>
            <td>COOKIE</td>
            <td>{&#36;Mo.cookie.name}，{&#36;Mo.cookie.person.age}</td>
            <td>{$Mo.cookie.name}，{$Mo.cookie.person.age}</td>
        </tr>
        <tr>
            <td>语言包</td>
            <td>{&#36;Mo.L.title}</td>
            <td>{$Mo.L.title}</td>
        </tr>
        <tr>
            <td>调用函数</td>
            <td>首参：{&#36;args:TestArg="第二个参数","第三个参数"}<br />
                中间参数：{&#36;args:TestArg="第一个参数",...,"第三个参数"}<br />
                尾参：{&#36;args:TestArg="第一个参数","第二个参数",...}<br />
                {&#36;birthday:F.formatdate="yyyy-MM-dd HH:mm:ss"}
                </td>
            <td>首参：{$args:TestArg="第二个参数","第三个参数"}<br />
                中间参数：{$args:TestArg="第一个参数",...,"第三个参数"}<br />
                尾参：{$args:TestArg="第一个参数","第二个参数",...}<br />
                {$birthday:F.formatdate="yyyy-MM-dd HH:mm:ss"}
            </td>
        </tr>
        <tr>
            <td>预编译标签</td>
            <td>{&#36;&#36;MO_ROOT}</td>
            <td>{$$MO_ROOT}</td>
        </tr>
        <tr>
            <td>预编译(U方法，建议)</td>
            <td>{&#36;&#36;U("home/test","id=2&name=anlige&version=\{&#36;Version\}","xml")}</td>
            <td>{$$U("home/test","id=2&name=anlige&version=\{$Version\}","xml")}</td>
        </tr>
        <tr>
            <td>U方法(普通)</td>
            <td>{&#36;U("home/test","id=2&name=anlige&version=2.1","xml")}</td>
            <td>{$U("home/test","id=2&name=anlige&version=2.1","xml")}</td>
        </tr>
        <tr>
            <td>U方法(无域名)</td>
            <td>{&#36;U("home/test!","id=2&name=anlige&version=2.1","xml")}</td>
            <td>{$U("home/test!","id=2&name=anlige&version=2.1","xml")}</td>
        </tr>
        <tr>
            <td>empty标签</td>
            <td>&lt;empty name="name"&gt;name为空&lt;/empty&gt;</td>
            <td><empty name="name">name为空</empty></td>
        </tr>
        <tr>
            <td>expression标签</td>
            <td>&lt;expression and="name eq Empty"&gt;name为空&lt;/expression&gt;</td>
            <td><expression and="name eq Empty">name为空</expression></td>
        </tr>
        <tr>
            <td>expression标签</td>
            <td>&lt;expression and="name eq Empty" and="appname eq Empty"&gt;<br />&nbsp; name和appname为空<br />&lt;/else&gt;<br />&nbsp; name和appname有一个不为空<br />&lt;/expression&gt;</td>
            <td><expression and="name eq Empty" and="appname eq Empty">name和appname为空</else>name和appname有一个不为空。name = {$name},appname = {$appname}</expression></td>
        </tr>
        <tr>
            <td>empty/else标签</td>
            <td>&lt;empty name="address"&gt;address为空&lt;/else&gt;address不为空：{&#36;address}&lt;/empty&gt;</td>
            <td><empty name="address">address为空</else>address不为空：{$address}</empty></td>
        </tr>
        <tr>
            <td>nempty标签</td>
            <td>&lt;nempty name="appname"&gt;appname不为空&lt;/nempty&gt;</td>
            <td><nempty name="appname">appname不为空</nempty></td>
        </tr>
        <tr>
            <td>eq标签</td>
            <td>&lt;eq name="appname" value="MoAspEnginer"&gt;appname为MoAspEnginer&lt;/eq&gt;</td>
            <td><eq name="appname" value="MoAspEnginer">appname为MoAspEnginer</eq></td>
        </tr>
        <tr>
            <td>自定义标签</td>
            <td>&lt;Test name="test" color="red" /&gt;</td>
            <td><Test name="test" color="red" /></td>
        </tr>
        <tr>
            <td>其他模块</td>
            <td>{&#36;appname:Mo.A.Other.Index}</td>
            <td>{$appname:Mo.A.Other.Index}</td>
        </tr>
        <tr><td>loop循环</td><td>
<pre>
&lt;ul&gt;
&lt;loop name="data"&gt;
    &lt;li&gt;条目：{&#36;value.name} - {&#36;value.age}&amp;nbsp; &lt;/li&gt;
&lt;/loop&gt;
&lt;/ul&gt;
</pre>
            </td><td>
	        <ul>
            <loop name="data">
                <li>条目：{$value.name} - {$value.age}&nbsp; </li>
            </loop>
        	</ul>
        </td></tr>
        <tr>
            <td>分页</td>
            <td>&lt;page for="data" /&gt;</td>
            <td><page for="data" /></td>
        </tr>
        <tr>
            <td>自定义url分页</td>
            <td>&lt;page for="data" url="?m=Home&a=Index&appname={&#36;#appname}" /&gt;</td>
            <td><page for="data" url="?m=Home&a=Index&page={#page}&appname={$#appname}" /></td>
        </tr>
        <tr><td>foreach循环</td>
            <td>
<pre>
&lt;foreach name="list"&gt;
    &lt;gt name="key" value="4"&gt;
{&#36;key} =&gt; &lt;span style="color:red"&gt;{&#36;value}&lt;/span&gt;&lt;br /&gt;
    &lt;/else&gt;
{&#36;key} =&gt; {&#36;value}&lt;br /&gt;
    &lt;/gt&gt;
&lt;/foreach&gt;
</pre>
            </td>
            <td>
            <foreach name="list">
                <gt name="key" value="4">
            {$key} =&gt; <span style="color:red">{$value}</span><br />
                </else>
            {$key} =&gt; {$value}<br />
                </gt>
            </foreach>
            </td>
        </tr>
        <tr><td>foreach循环</td>
            <td>
<pre>
&lt;foreach name="jsobject"&gt;
    {&#36;key} =&amp;gt; {&#36;value} =&amp;gt; {&#36;value:md5}&lt;br /&gt;
&lt;/foreach&gt;
</pre>
            </td>
            <td>
            <foreach name="jsobject">
                {$key} =&gt; {$value} =&gt; {$value:md5}<br />
            </foreach>
            </td>
        </tr>
        <tr><td>switch</td><td>
<pre>
&lt;switch name="age"&gt;
    &lt;case value="23" type="number" /&gt;
        我23岁了。&lt;break /&gt;
    &lt;case value="24" type="number" /&gt;
        我24岁了。&lt;break /&gt;
    &lt;default /&gt;
        我{&#36;age}岁了!!!!
&lt;/switch&gt;    
</pre>
            </td><td>
            <switch name="age">
                <case value="23" type="number" />
                    我23岁了。<break />
                <case value="24" type="number" />
                    我24岁了。<break />
                <default />
                    我{$age}岁了!!!!
            </switch>
        </td></tr>
        <tr>
            <td>验证码</td>
            <td>Safecode("sessionname", {length:4, padding:5, odd:3, font:'yahei'});</td>
            <td><img src="?a=Safecode" onclick="this.src='?a=Safecode&r=' + Math.random()" style="cursor:pointer" /> *点击刷新</td>
        </tr>
    </tbody>
</table>
<include file="foot.html" />